#ifndef TABLEMODEL_H
#define TABLEMODEL_H

#include <QAbstractTableModel>
#include <QByteArray>
#include <QDebug>
#include "types.h"

class TableModel : public QAbstractTableModel
{
    Q_OBJECT
public:
    explicit TableModel(QObject *parent = 0);
    ~TableModel();

signals:
    void searchResult(int);
    void searchEnd(int, int);

public slots:
    int rowCount(const QModelIndex & parent = QModelIndex()) const;
    int	columnCount(const QModelIndex & parent = QModelIndex()) const;
    void setData(QByteArray array);
    QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;
    QByteArray getBytes(const QModelIndex & index, int length);
    void setAddrFormat(DISPLAY_FORMAT_EN format);
    void setFirstFormat(DISPLAY_FORMAT_EN format);
    void setSecFormat(DISPLAY_FORMAT_EN format);
    void setFirstEndian(DISPLAY_ENDIAN_EN format);
    void setSecEndian(DISPLAY_ENDIAN_EN format);

    void search(QByteArray bytes, int start = 0);

private:
    QByteArray array;

    DISPLAY_FORMAT_EN enAddrFormat;
    DISPLAY_FORMAT_EN enFirstFormat;
    DISPLAY_FORMAT_EN enSecFormat;
    DISPLAY_ENDIAN_EN enFirstEndian;
    DISPLAY_ENDIAN_EN enSecEndian;
};

#endif // TABLEMODEL_H
